package com.x.uikit.link;

import java.util.HashMap;

public class XParams extends HashMap<String, Object> {
    public XParams() {
    }

    private static Object get(XParams params, String key, Object defaultValue) {
        return params != null && params.containsKey(key) ? params.get(key) : defaultValue;
    }

    public static <T> T fetch(XParams params, String key, Class<T> checkType, T defaultValue) {
        Object obj = get(params, key, defaultValue);
        return obj != null && checkType.isInstance(obj) ? (T) obj : defaultValue;
    }

    public static XParams obtain() {
        return new XParams();
    }

    public static XParams obtain(String key, Object value) {
        XParams params = new XParams();
        params.put(key, value);
        return params;
    }
}